#include <REGX52.H>
#include "Delay.h"


sbit RCK   = P3^5;    //RCLK
sbit SCK = P3^6;	  //SRCLK
sbit SER   = P3^4;	  //SER


/**
  *@brief  74HC595写入一个字节
  *@param  要写入的字节
  *@retval 无
  */
void _H74HC595_WriteByte(unsigned char Byte)
{
	unsigned char i = 0;
	for (i = 0;i < 8;i++)
	{
//		1位   0x..  这种情况下等号右边非0即1
		SER = Byte & (0x80 >> i);//注意理解!!!
		
		SCK = 1;//上升沿移位
		SCK = 0;//准备下一次移位
	}
	RCK = 1;//上升沿锁存
	RCK = 0;
}


/**
  *@brief  LED点阵屏显示一列数据
  *@param  Col  列[0~7(0在最左边)]
  *@param  Row  行（0x00 ~ 0xFF）
  *@retval 无
  */
void MatrixLED_ShowColumn(unsigned char Col,Row)
{
	_H74HC595_WriteByte(Row);
	P0 = ~(0x80 >> Col);
	Delay(1);
	P0 = 0xFF;
}

void main()
{
	SCK = 0;
	RCK = 0;
	P0_7 = 0;
	
	while(1)
	{
		MatrixLED_ShowColumn(0,0x18);
		MatrixLED_ShowColumn(1,0x24);
		MatrixLED_ShowColumn(2,0x42);
		MatrixLED_ShowColumn(3,0x21);
		MatrixLED_ShowColumn(4,0x21);
		MatrixLED_ShowColumn(5,0x42);
		MatrixLED_ShowColumn(6,0x24);
		MatrixLED_ShowColumn(7,0x18);
	}
}



















